require 'View/UIBase/UIBase'
require "Common/define"
require "Logic/Config"
require "Common/functions"
local UIGuildSkin = require "View/UIGuild/Skin/UIGuildSkin"

UIGuild = UIBase.New(PanelNames.UIGuild);

--二级面板和参数
function UIGuild.Init(subPanelName)
    UIGuild.subPanelName = subPanelName;
    UIBase.Init(UIGuild);
end

---@param obj GComponent
function UIGuild:OnCreate()
    self.viewSkin = UIGuildSkin.New(self.fguiObj);
    self.viewSkin:setCloseCallback(self.OnBack,self);
    if self.subPanelName == "GuildHall" then
        self.viewSkin:onTouch_Btn_Guildhall();
    elseif self.subPanelName == "GuildWar" then
        self.viewSkin:onTouch_Btn_gvg();
    elseif self.subPanelName == "GuildBoss" then
        self.viewSkin:onTouch_Btn_Guildleader();
    elseif self.subPanelName == "GuildShop" then
        self.viewSkin:onTouch_Btn_Guildshop();
    elseif self.subPanelName == "GuildInvestment" then
        self.viewSkin:onTouch_Btn_Guildinvestment();
    elseif self.subPanelName == "Guildwish" then
        self.viewSkin:onTouch_Btn_Guildwish();
    end
end

function UIGuild:OnJump( subPanelName )
    self.subPanelName = subPanelName
    if self.subPanelName == "GuildHall" then
        self.viewSkin:onTouch_Btn_Guildhall();
    elseif self.subPanelName == "GuildWar" then
        self.viewSkin:onTouch_Btn_gvg();
    elseif self.subPanelName == "GuildBoss" then
        self.viewSkin:onTouch_Btn_Guildleader();
    elseif self.subPanelName == "GuildShop" then
        self.viewSkin:onTouch_Btn_Guildshop();
    elseif self.subPanelName == "GuildInvestment" then
        self.viewSkin:onTouch_Btn_Guildinvestment();
    elseif self.subPanelName == "Guildwish" then
        self.viewSkin:onTouch_Btn_Guildwish();
    end
end

function UIGuild:OnBack()
    self.backFunc = nil;
    DestoryUI(self._panelName)
    AudioManager.RefreshBGM()
end

function UIGuild:OnDestroy()
    self.viewSkin:OnDestroy();
    AudioManager.PlayBGMOnCloseUI("UIGuild")
end

return UIGuild;